<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>查询属性的另外写法</title>
</head>

<body>
  <script>
    // 查询属性的另外写法  对象['属性'] 这个属性必须加引号

    let age = 'age'
    let obj = {
      'first-name': 'xpp',
      name: 'yy',
      age: 18
    }
    console.log(obj.name);   //yy

    console.log(obj['name']);   //yy

    console.log(obj[name]);  //undefined 失败


    console.log(obj['first-name']);   //解析对象里面存在带引号的取值问题


    console.log(obj.age);  //调用obj里面的age

    console.log(obj[age]);   
    //let age==='age'   ==obj['age']  外面定义了一个age  进行解析




  </script>
</body>

</html>